//
//  PhotoCViewCell.m
//  Travel_M_Travel
//
//  Created by Sun on 15/4/5.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "PhotoCViewCell.h"

@implementation PhotoCViewCell

- (void)dealloc
{
    [_imageView release];
    [_name release];
    [_aboutPho release];
    [super dealloc];
}

- (instancetype) initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView = [[UIImageView alloc] init];
        _imageView.clipsToBounds = YES;
        _imageView.layer.cornerRadius = 5;
        [self addSubview:_imageView];
        [_imageView release];
        
        self.name = [[UILabel alloc] init];
        _name.textColor = [UIColor whiteColor];
        _name.font = [UIFont boldSystemFontOfSize:12];
        [_imageView addSubview:_name];
        [_name release];
    }
    return self;
}


- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    _imageView.frame = CGRectMake(0, 0, 140, 140);
    _name.frame = CGRectMake(0, 100, self.frame.size.width - 20, 35);
    _name.textAlignment = NSTextAlignmentRight;
}

- (void)setAboutPho:(AboutPhotoData *)aboutPho
{
    if (_aboutPho != aboutPho) {
        [_aboutPho release];
        _aboutPho = [aboutPho retain];
        }
    NSString *str = self.aboutPho.photo_1600;
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:str];
    [_imageView setImageWithURL:url];
    
    _name.text = [self.aboutPho.poi objectForKey:@"name"];
}

@end
